setlocal EnableDelayedExpansion

set CCPATH=

set CC=%CCPATH%gcc
set LINK=%CCPATH%ld

set OBJDIR=kernel\obj

set KDIR=kernel\kernel
set LIBDIR=kernel\lib
set DRVDIR=kernel\drv
set ENTRY=kernel\entry\entry.c
set ENTRYOBJ=kernel\obj\entry.o

set C_INCLUDE_PATH=kernel\h
set LIBRARY_PATH=

set LIBLIST=
set SRCLIST=
set DRVLIST=

set OLDOBJ=obj

set IMAGENAME=K32.exe

for %%I in (%KDIR%\*.C) do %CC% -Wall -c %%I -o%OBJDIR%\%%~nI.o

for %%I in (%KDIR%\*.C) do %CC% -Wall -S %%I -o%OBJDIR%\%%~nI.s

for %%I in (%KDIR%\*.C) do set SRCLIST=!SRCLIST! %OBJDIR%\%%~nI.o


for %%I in (%LIBDIR%\*.C) do %CC% -Wall -c %%I -o%OBJDIR%\%%~nI.o

for %%I in (%LIBDIR%\*.C) do %CC% -Wall -S %%I -o%OBJDIR%\%%~nI.s

for %%I in (%LIBDIR%\*.C) do set LIBLIST=!LIBLIST! %OBJDIR%\%%~nI.o


for %%I in (%DRVDIR%\*.C) do %CC% -Wall -c %%I -o%OBJDIR%\%%~nI.o

for %%I in (%DRVDIR%\*.C) do %CC% -Wall -S %%I -o%OBJDIR%\%%~nI.s

for %%I in (%DRVDIR%\*.C) do set DRVLIST=!DRVLIST! %OBJDIR%\%%~nI.o

%CC% -c %ENTRY% -o%ENTRYOBJ%

%LINK% -o%OBJDIR%\%IMAGENAME% -Ttext 0x20000 %ENTRYOBJ% %SRCLIST% %LIBLIST% %DRVLIST%

copy /y %OBJDIR%\%IMAGENAME% %OLDOBJ%\%IMAGENAME%

